<script type="text/javascript" charset="utf-8">
	jQuery(document).ready(function($){
		
		$('input.color').ColorPicker({
			onSubmit: function(hsb, hex, rgb, el) {
				$(el).val(hex);
				$(el).ColorPickerHide();
				$(el).trigger('change');
			},
			onBeforeShow: function () {
				$(this).ColorPickerSetColor(this.value);
			}
		})
		.bind('keyup', function(){
			$(this).ColorPickerSetColor(this.value);
		});
		
		$("#coupon-border-color").change(function(){
			var color = $(this).val();
			$(".couponcodes").css('border-color', '#' + color);
		});
		
		$("#coupon-bg-color").change(function(){
			var color = $(this).val();
			$(".couponcodes").css('background-color', '#' + color);
		});
		
		$("#coupon-text-color").change(function(){
			var color = $(this).val();
			$(".couponcodes p").css('color', '#' + color);
		});
		
		$("#coupon-code-color").change(function(){
			var color = $(this).val();
			$(".couponcodes .coupon-code").css('color', '#' + color);
		});
		
		$("#coupon-code-bg-color").change(function(){
			var color = $(this).val();
			$(".couponcodes .coupon-code").css('background-color', '#' + color);
		});
		
		$("#coupon-width").keyup(function(){
			var w = $(this).val();
			if (parseInt(w, 10) > 0)
				$(".couponcodes").width(w);
		});
		
		$('input.color').trigger('change'); $("#coupon-width").trigger('keyup');
		$('.coupon-wrapper').show();
		
	})
</script>



<?php global $wvcr; ?>

<div class="wrap">
<?php screen_icon( 'option-main' ); ?>
<h2>
	<?php _e("Options") ?> 
</h2>

<?php if ( $notice ) : ?>
	<div id="notice" class="error"><p><?php echo $notice ?></p></div>
<?php endif; ?>
<?php if ( $message ) : ?>
	<div id="message" class="updated"><p><?php echo $message; ?></p></div>
<?php endif; ?>

<?php while ( have_posts() ) : the_post(); ?>

<form action="<?php echo get_option_link(get_the_ID()) ?>" method="post" id="coupon-options">
	<input type="hidden" name="post_type" value="coupon">
	<input type="hidden" name="page" value="coupon-options">
	<input type="hidden" name="post" value="<?php the_ID() ?>">
	
	<div id="col-container">
		<div id="wvcr-col-right">
			<div class="coupon-wrapper" style="display: none;">
				<div class="couponcodes">
					<p>
						<span class="coupon-title"><?php the_title() ?></span>
						<span class="coupon-saved"><?php _e('You Save: '); $wvcr->coupon_mb->the_value('saved') ?></span>
						<br/>
						<span class="coupon-desc"><?php echo strip_tags(get_the_content()) ?></span>
						<span class="coupon-code"><?php echo strtoupper($wvcr->coupon_mb->get_the_value('couponcode')) ?></span>
						<br class="clear"/>
					</p>
				</div>
				<p class="coupon-note"><?php _e('* click to copy code and open website.') ?> <?php _e('Coupon Expires: ') ?> <?php   $wvcr->coupon_mb->the_value('enddate')?></p>
			</div>
			
			
		</div>
		<div id="wvcr-col-left">
			<p>
				<label for="coupon-border-color"><?php _e('Border Color') ?></label>
				<input id="coupon-border-color" name="border_color" class="color" type="text" value="<?php echo $border_color ?>" />
			</p>
			
			<p>
				<label for="coupon-bg-color"><?php _e('Background Color') ?></label>
				<input id="coupon-bg-color" name="bg_color" class="color" type="text" value="<?php echo $bg_color ?>" />
			</p>
			
			<p>
				<label for="coupon-text-color"><?php _e('General Text Color') ?></label>
				<input id="coupon-text-color" name="text_color" class="color" type="text" value="<?php echo $text_color ?>" />
			</p>
			
			<p>
				<label for="coupon-code-color"><?php _e('Code Text Color') ?></label>
				<input id="coupon-code-color" name="code_color" class="color" type="text" value="<?php echo $code_color ?>" />
			</p>
			
			<p>
				<label for="coupon-code-bg-color"><?php _e('Code Background Color') ?></label>
				<input id="coupon-code-bg-color" name="code_bg_color" class="color" type="text" value="<?php echo $code_bg_color ?>" />
			</p>
			
			<p>
				<label for="coupon-width"><?php _e('Width') ?></label>
				<input id="coupon-width" name="width" type="text" value="<?php echo $width ?>" />
			</p>
			
			<p>
			<label for="coupon-shortcode"><?php _e('Coupon Shortcode') ?></label>	
			<input type="text" id="coupon-shortcode" value="[coupon id=<?php the_ID() ?>]" />
			</p>
			
		</div>
	</div>
	
	<p class="submit">
		<input type="submit" name="submit" value="Save" class="button-primary"/>
	</p>

</form>	

<?php endwhile; // End the loop. Whew. ?>

</div>